import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import SearchView from '@/views/SearchView.vue'
import NotFound from '@/views/NotFound.vue'

const routes = [
  //重定向到首页
  { path: '/', redirect: '/home' },
  { path: '/home', component: HomeView },
  { path: '/search/:words?', name: 'search', component: SearchView },

  //404页面
  { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound }
]

const router = createRouter({
  // history: createWebHashHistory(),
  history: createWebHistory(),
  routes
})

export default router
